<template>
  <div class="public_main">
    <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>{{$t('sidebar.borrowBack')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('loanAfterManage.crumbsOne')}}</el-breadcrumb-item>
        <el-breadcrumb-item>{{$t('loanAfterManage.crumbsTen')}}</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <!-- -------------搜索查询栏------------------------ -->
    <search 
			:searchData="searchData" 
			@search="search" 
			:searchRight="true"
			:outputRight="false"
    ></search>
    <!-- -------------表单显示栏------------------------ -->
    <!-- <div class="table" v-if="$store.state.common.permiss.includes('RIGHT_ACCOUNT_LENDING_LIST')"> -->
    <div class="table">
      <template>
        <el-table :data="tableData" stripe size="small" v-loading="loadFlag">
          <el-table-column align="center" prop="orderId" :label="$t('public.orderId')"></el-table-column>
          <el-table-column align="center" prop="userName" :label="$t('public.userName')"></el-table-column>
          <el-table-column align="center" prop="userPhone" :label="$t('public.userPhone')"></el-table-column>
          <el-table-column align="center" prop="adminName" :label="$t('loanAfterManage.no8')"></el-table-column>
          <el-table-column align="center" prop="reduceAmount" :label="$t('operationDetail.no48')"></el-table-column>
          <el-table-column align="center" prop="operateTime" :label="$t('loanAfterManage.no9')"></el-table-column>
        </el-table>
      </template>
    </div>
    <!-- ------------  分页显示栏  ------------------------ -->
    <el-row type="flex" justify="end">
      <div class="pages" >
        <el-pagination
          @current-change="handleCurrentChange"
          :current-page="pagination.current"
          layout="sizes, prev, pager, next, total,->"
          :page-sizes="pagination.pageSizeOptions"
          :page-size="pagination.pageSize"
          @size-change="handleSizeChange"
          :total="pagination.total">
        </el-pagination>
      </div>
    </el-row>
    <div class="foot"></div>

  </div>
</template>
<script>
export default {
  name: 'myCollectionList',
  data () {
    const searchData=[
      {
        type: 'input',
        label: 'public.orderId',
        attr: 'orderId',
        value: ''
      },
      {
        type: 'input',
        label: 'public.name',
        attr: 'userName',
        value: ''
      },{
        type: 'input',
        label: 'public.userTel',
        attr: 'userPhone',
        value: ''
      },{
        type: 'filter',
        attr: 'adminName',
        label: 'loanAfterManage.no8',
        option: this.$store.state.options.collection_option,
        value: '',
        langFlag: true,
      },{
        type: 'date',
        label: 'loanAfterManage.no9',
        attr: 'operateTime',
        value: '',
        langFlag: false,
      },
      ]
    return {
      flag: true,
      loadFlag: true,
      pagination: {
        pageSize: global.config.pageSize,
        pageSizeOptions: global.config.pageSizeOptions,
        current: 1,
        total: 0,
      },
      searchData:searchData,
      formInline: {},// 用户查询信息数据对应字段
      tableData: []// 用户信息数据模拟
    }
  },
  methods: {
    handleSizeChange (val) {// 每页条数变化时操作
      this.pagination.pageSize = val;
      this.getTableData();
    },
    handleCurrentChange (val) { // 分页按钮点击操作
      this.pagination.current = val;
      this.getTableData();
    },
    search(search) { // 搜索
      this.formInline = {
        orderId: search.orderId,
        userName:search.userName,
        userPhone: search.userPhone,
        adminName: search.adminName,
        operateTime: search.operateTime,
      };
      if (this.flag) {
        this.pagination.currentPage = 1;
        this.flag = false;
        this.getTableData();
      }
      
    },
    getTableData () { // 放款列表获取
      this.loadFlag = true;
      let option = {
        pageNum:this.pagination.current,
        pageSize:this.pagination.pageSize,
        param: {
          partnerId:sessionStorage.partnerId,
          ...this.formInline
        }       
      }
      this.$axios.post(this.$action.collection_concessions, option).then(res => {
        this.flag = true;
        if (res.code == 200) {
          this.tableData = res.data.list;
          this.pagination.total = res.data.total;
        }else{
          this.$globalMsg.error(res.message)
        }
        this.loadFlag = false;
      })
    },
    getadminName(){//获取借款放款渠道下拉框数据
      let option = {
        param:{
          userName:''
        }
      }
      this.$axios.post(this.$action.collection_adminList, option).then(res => {
        if (res.code == 200) {
          let arr = []
          res.data.forEach(item=>{
            arr.push({value:item.userName,label:item.userName})
          })
          this.searchData.filter(value=>value.attr=='adminName')[0].option = arr
				}
      })
    },
    detail (userId, orderId,waitAmount) { // 查看详情点击操作
      this.$router.push({path: '/CollectionDetail', query: {userId, orderId,waitAmount,'collection':1}});
    }
  },
  mounted () {
    this.getTableData();
    this.getadminName();
  }
}
</script>
<style scoped lang="scss"></style>
